<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>新增客户信息</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/themes/icon.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/demo.css"/>
<script src="${pageContext.request.contextPath }/plugins/jQuery/jquery.min.js"></script>
<script src="${pageContext.request.contextPath }/plugins/jQuery/jquery.easyui.min.js"></script>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/admin/css/input1.css"/>
<script src="${pageContext.request.contextPath }/admin/js/reg.js"></script>
<script>
	$(function(){
//		$.messager.alert('系统消息','子栏目删除成功！');
		$('#fb').filebox({ 
		 	buttonText: '请选择文件', 
		 	buttonAlign: 'right',
		 	editable:false 
		});

		// 地推人员下拉列表
		$('#salesman').combobox({
			valueField:'userid',
			textField:'username',
			url:'${pageContext.request.contextPath }/admin/user/listUserByRole/4'
		});
		$('#salesman').combobox("setValue",${customer.SALESMAN});
				
		// 站点下拉列表
		$('#stationId').combobox({
			valueField:'station_id',
			textField:'station_name',
			url:'${pageContext.request.contextPath }/admin/station/findStationByKind/1'
		});
		$('#stationId').combobox("setValue",${customer.STATION_ID});
		
		// 提货仓列表
		$('#takeStationId').combobox({
			valueField:'station_id',
			textField:'station_name',
			url:'${pageContext.request.contextPath }/admin/station/findStationByKind/1'
		});
		$('#takeStationId').combobox("setValue",${customer.TAKE_STATION_ID});
		$("a[name='qsave']").linkbutton({text:'保存客户信息',plain:true,iconCls:'icon-ok'});
		$("a[name='upload']").linkbutton({text:'重新上传',plain:true,iconCls:'icon-my-add'});
		$("a[name='find']").linkbutton({text:'点击查看',plain:true,iconCls:'icon-my-find'});
		$("a[name='qback']").linkbutton({text:'返回商品列表',plain:true,iconCls:'icon-back'});
		$('#dlg').dialog('close');
		
	});
	
	function doSub(){
		var cname=$('#cname').val();
		if($.trim(cname)==''){
			$.messager.alert('系统消息','<span style="color:red;">客户姓名必须输入！</span>');
			$('#cname').textbox('textbox').focus(); 
    		return;
		}
		var mobile=$('#mobile').val();
		if(!isValidMobilePhone(mobile)){
			$.messager.alert('系统消息','<span style="color:red;">电话号码必须输入，且必须是11位数字！</span>'); 
    		return;
		}
		var salesman=$('#salesman').combobox("getValue");
		if(salesman==-1){
			$.messager.alert('系统消息','<span style="color:red;">地推人员必须选择<br/>[备注：请直接选择地推人员]</span>');
			return;
		}
		var stationId=$('#stationId').combobox("getValue");
		if(stationId==-1){
			$.messager.alert('系统消息','<span style="color:red;">客户所属站点必须选择<br/>[备注：目前请将所属站点和提货仓保持一致]</span>');
			return;
		}
		var takeStationId=$('#takeStationId').combobox("getValue");
		if(takeStationId==-1){
			$.messager.alert('系统消息','<span style="color:red;">客户所属提货仓必须选择<br/>[备注：目前请将所属站点和提货仓保持一致]</span>');
			return;
		}
		if(stationId!=takeStationId){
			$.messager.alert('系统消息','<span style="color:red;">请将客户所属提货仓和客户所属站点选择一样的内容！</span>');
			return;
		}
		$('#addCustomer').submit();
	}
	
	function showImg(imgUrl){
		$('#dlg').dialog('open');
		var image=document.getElementById("stationImg");
		image.setAttribute("src",imgUrl );
	}
	
	function uploadImg(){
		$('#upload').hide();
		$('#uploadFile').show();
	}
</script>
</head>

<body>
<form method="post" id="addCustomer" action="${pageContext.request.contextPath }/admin/customer/editCustomer" enctype="multipart/form-data">
<div class="i-container" style="width:1000px;">
	<div class="i-common i-title">添加客户信息
		<span style="color:red; margin-left:30px;">${addMsg }</span>
		<div class="i-btn">
			<a id="btn" href="javascript:doSub()" name="qsave"></a>
			<a id="btn" href="javascript:history.go(-1)" name="qback"></a>
		</div><div style=" clear:both;"></div>
	</div>
    <div class="i-common i-cnt-left">客户姓名：</div><div class="i-common i-cnt-right">
    	<input name="customer.CUST_NAME" id="cname" class="easyui-textbox" style="width:210px;height:26px" value="${customer.CUST_NAME }"/>
    	<input type="hidden" name="customer.CUST_ID" value="${customer.CUST_ID }"/>
    	<input type="hidden" name="customer.MARKET_ADDRESS" value="${customer.MARKET_ADDRESS }"/>
    	<input type="hidden" name="customer.CREATE_TIME" value="${customer.CREATE_TIME }"/>
    </div>
    <div class="i-common i-cnt-middle">客户性别：</div>
    <div class="i-common i-cnt-right">
    	<c:choose>
    		<c:when test="${customer.CUST_SEX eq 1 }">
    			<input type="radio" name="customer.CUST_SEX" value='0' />男&nbsp;&nbsp;&nbsp;
    			<input type="radio" name="customer.CUST_SEX" value='1' checked="checked"/>女
    		</c:when>
    		<c:otherwise>
    			<input type="radio" name="customer.CUST_SEX" value='0' checked="checked"/>男&nbsp;&nbsp;&nbsp;
    			<input type="radio" name="customer.CUST_SEX" value='1' />女
    		</c:otherwise>
    	</c:choose>  	
    </div>
    <div class="i-common i-cnt-middle">手机号码：</div>
    <div class="i-common i-cnt-right">
    	<input name="customer.MOBILE" id="mobile" class="easyui-textbox" style="width:210px;height:26px" value="${customer.MOBILE }"/>
    </div>
    <div style="clear:both;"></div>
    <div class="i-common i-cnt-left">身份证号：</div>
    <div class="i-common i-cnt-right">
    	<input name="customer.CUST_IDENTITY" id="identity" class="easyui-textbox" style="width:210px;height:26px" value="${customer.CUST_IDENTITY }"/>
    </div>
    <div class="i-common i-cnt-middle">身份证图片：</div>
    <div class="i-common i-cnt-right">
    	<input type="hidden" name="customer.IDENTITY_URL" value="${customer.IDENTITY_URL }"/>
   		<c:choose>
			<c:when test="${customer.IDENTITY_URL eq null }">
				<div id="uploadFile"><input class="easyui-filebox" name="img" data-options="prompt:'请选择身份证图片...'" style="width:210px;height:26px" accept="image/gif,image/jpeg,image/png"/></div>
			</c:when>
			<c:when test="${customer.IDENTITY_URL ne null }">
				<div id="uploadFile" style="display:none;"><input class="easyui-filebox" name="img" data-options="prompt:'请选择身份证图片...'" style="width:210px;height:26px" accept="image/gif,image/jpeg,image/png"/></div>
				<div id="upload">
 					<span style="width:130px; font-size:12px;color:red;">已上传</span>	    					
 					<a id="btn" href="javascript:showImg('${ customer.IDENTITY_URL}')" name="find"></a>
 					<a id="btn" href="javascript:uploadImg()" name="upload"></a>
				</div>
			</c:when>
		</c:choose>
    </div>
    <div class="i-common i-cnt-middle">地推人员：</div>
    <div class="i-common i-cnt-right">
    	<input name="customer.SALESMAN" id="salesman" class="easyui-textbox" style="width:210px;height:26px"/>
    </div>
    <div style="clear:both;"></div> 
    <div class="i-common i-cnt-left">所属站点：</div>
    <div class="i-common i-cnt-right">
		<input name="customer.STATION_ID" id="stationId" class="easyui-textbox" style="width:210px;height:26px"/>
	</div>
    <div class="i-common i-cnt-middle">所属提货仓：</div>
    <div class="i-common i-cnt-right">
    	<input name="customer.TAKE_STATION_ID" id="takeStationId" class="easyui-textbox" style="width:210px;height:26px"/>
    </div>
    <div class="i-common i-cnt-middle">是否有效：</div>
    <div class="i-common i-cnt-right">
    	<c:choose>
    		<c:when test="${customer.IS_VALID eq 1 }">
    			<input type="radio" name="customer.IS_VALID" value='1' checked="checked"/>正常使用&nbsp;&nbsp;&nbsp;
    			<input type="radio" name="customer.IS_VALID" value='0'/>禁止使用
    		</c:when>
    		<c:otherwise>
    			<input type="radio" name="customer.IS_VALID" value='1'/>正常使用&nbsp;&nbsp;&nbsp;
    			<input type="radio" name="customer.IS_VALID" value='0' checked="checked"/>禁止使用
    		</c:otherwise>
    	</c:choose>
    	
    </div>
    <div style="clear:both;"></div>
    
    <div class="i-common i-cnt-left">客户摊位：</div>
    <div class="i-common i-cnt-right">
		<input name="customer.POSITION" id="stationId" class="easyui-textbox" style="width:210px;height:26px" value="${customer.POSITION }"/>
	</div>
    <div class="i-common i-cnt-middle">市场地址：</div>
    <div class="i-common i-cnt-right">
    	<input name="customer.MARKET_ADDRESS" id="stationId" class="easyui-textbox" style="width:210px;height:26px" value="${customer.MARKET_ADDRESS }"/>
    </div>
    <div class="i-common i-cnt-middle">&nbsp;</div>
    <div class="i-common i-cnt-right">
    	&nbsp;
    </div>
    <div style="clear:both;"></div>
</div>
<div id="dlg" class="easyui-dialog" title="身份证图片查看" style="width:490px;height:340px;max-width:800px;padding:10px" data-options="
		onResize:function(){
			$(this).dialog('center');
		}">
		<img id="stationImg" src="" style="width:450px;height:270px;"/>
</div>
</form>
</body>
</html>
